﻿<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ Import Namespace="System.IO" %>

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Buffer = true;
        Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
        Response.Expires = 0;
        Response.CacheControl = "no-cache";   
    }

    protected void btnExport_Click(object sender, EventArgs e)
    {
        string filePath = this.filePath.Value;
        if (!File.Exists(filePath))
        {
            using (StreamWriter sw = File.CreateText(filePath))
            {
                sw.WriteLine(this.hidDiaryContent.Value);
            }
        }
        else
        {
            File.AppendAllText(filePath, this.hidDiaryContent.Value, Encoding.UTF8);
        }
        ScriptManager.RegisterClientScriptBlock(Page, GetType(), "", "alert('日记导出完毕！');window.close();", true); 
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>导出文件</title>
    <base target="_self" />
    <script type="text/javascript" src="../../js/MyOption.js"></script>
</head>
<body bgcolor="#EEEEEE" onload="getSendParameter('hidDiaryContent')" topmargin="0" leftmargin="0">
    <form id="form1" runat="server">
        <table bgcolor="black" style="" width="100%" height="" align="center" cellpadding="1" cellspacing="1">
            <tr>
                <td align="center" height="30px" colspan="2" background="../CSS/Snap1.jpg">
                    <font style="font-size:12px">导出文件对话框</font>
                </td>
            </tr> 
            <tr bgcolor="white">
                <td style="width: 71px">
                    <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Smaller" Text="文件路径："
                        Width="74px"></asp:Label></td>
                <td>
                    <input id="filePath" runat="server" style="width: 100%" type="file" /></td>
            </tr>
            <tr>
                <td style="height: 27px" background="../CSS/Snap1.jpg" colspan="2" align="center">
                    <asp:Button ID="btnExport" runat="server" OnClick="btnExport_Click" OnClientClick="return checkTargetPath('filePath')"
                        Text="导出" Width="80px" />
                    <input id="hidDiaryContent" runat="server" name="hidDiaryContent" type="hidden" /></td>
            </tr>
        </table>
    </form>
</body>
</html>
